﻿using CUREBusinessLogicLayer.Harmful;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace CURE.Handler
{
    /// <summary>
    /// FileDeleteHandler 的摘要说明
    /// </summary>
    public class FileDeleteHandler : IHttpHandler
    {
        private LedgerBll ledgerbll = new LedgerBll();

        public void ProcessRequest(HttpContext context)
        {
            string id = context.Request.Form["id"];
            string path = context.Request.Form["path"];
            path = context.Server.MapPath("~" + path);
            if (DeleteFile(id))
            {
                File.Delete(path);
                context.Response.Write("success");
            }
            else
            {
                context.Response.Write("fail");
            }
            

        }

        private bool DeleteFile(string id)
        {
            return ledgerbll.DeleteFile(id);
        }


        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}